package com.test.QtestServer.mapper;

import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;

import com.test.QtestServer.pojo.Tokens;

@Mapper
public interface TokenMapper {

    @Insert("INSERT INTO tokens(user_id,token,expired_time,create_time) VALUES(#{user_id},#{token},DATE_ADD(NOW(),INTERVAL 1 HOUR),NOW())")
    void addToken(Integer user_id,String token);

    @Select("SELECT * FROM tokens WHERE token=#{token} AND expired_time>NOW()")
    Tokens findActiveToken(String token);
}
